program summa;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  summator = class
    n: integer;
    procedure sum; virtual;
  end;
{ summator }
  smartsummator = class (summator)
    procedure sum; override;
  end;

procedure summator.sum;
var
  v, i: integer;
begin
  v:= 0;
  for i := 1 to n do
    v:=v+i;
  writeln(v);
end;

{ smartsummator }

procedure smartsummator.sum;
begin
  writeln(n*(n+1)div 2);
end;
var
  s1: summator;
  n:integer;
begin
  s1:=summator.Create;
  readln(n);
  s1.n:=n;
  s1.sum;
  s1:=smartsummator.Create;
  s1.n:=n;
  s1.sum;
  Readln;
end.
